package newcoder_exp.justPractise;

import org.junit.Test;

public class NC112 {
    public class Solution {
        public String solve (int M, int N) {
            boolean flag = true;
            if (M < 0) {
                flag = false;
                M = -M;
            }
            int t = M, g;
            char c = ' ';
            StringBuilder sb = new StringBuilder();
            while (t > 0) {
                g = t % N;
                if (g < 10) {
                    c = (char)(g + '0');
                } else {
                    c = (char)(g + 'A' - 10);
                }
               sb.insert(0, c);
               t /= N;
            }
            if (!flag) {
                sb.insert(0, '-');
            }
            return sb.toString();
        }
    }
    @Test
    public void test() {
        Solution s = new Solution();
        System.out.println(s.solve(-23, 12));;        
    }
}
